<template>
  <div class="container">
    <div class="content">
      <router-view :key="$route.fullPath" />
    </div>
    <br>
    <br>
    <bottombar />
  </div>
</template>

<script lang="ts">
import { SingletonState } from "../interface";
import bottombar from "./views/mobile/mobile_bar.vue";
import {useStore} from "vuex";

export default {
  components: {
    bottombar,
  },
  created() {
    (this as any).applyPersonStates();
    useStore().dispatch('initAllAssociation');
  },
  methods:{
    async applyPersonStates(){
      fetch("api/authorize/self")
          .then(res=>{
            // console.log(res.status);
            if(res.status==200){
              sessionStorage['login']=SingletonState.logined;
            }else{
              sessionStorage['login']=SingletonState.notlogin;
            }
          }) //定义返回的类型和数据格式
    }
  }
};
</script>
<style lang="scss">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}
body {
  margin: 0;
}
#nav {
  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
* {
  box-sizing: border-box;
}
.container {
  display: flex;
  width: 100vw;
  min-height: 100vh;
  overflow-x: hidden;
  .content {
    width: 100%;
    height: auto;
  }
}
</style>
